$(function () {
    toggleLoading(true);
    var getParams = getArgs();
    var currentHotel = getParams.hotel;
    var roomType = getParams.roomType;
    var startDate = getParams.startDate;
    var endDate = getParams.endDate;
    window.face = '';
    window.back = '';
    window.vipInfoId ='';
    window.rooms = 1;
    window.nights = 1;
    window.adminId ='';
    var isWechatBrowser = function() {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
            return true;
        } else {
            return false;
        }
    };
    
    if(getParams.room != undefined){
        var roomId = (getParams.room).split(','); 
        window.roomFirst =roomId[0];
    }
    toastr.options = {
        "newestOnTop": false,
        "timeOut": 1500,
        "extendedTimeOut": 0,
        "escapeHtml": true,
        "positionClass": "toast-bottom-center"
    };
    if (currentHotel === undefined || currentHotel === '') {
        toastr.error(lang('toastr.grogshop'));
        return;
    }
    if (roomType === undefined || roomType === '') {
        toastr.error(lang('toastr.charmber'));
        return;
    }
    if (startDate === undefined || startDate === '') {
        toastr.error(lang('toastr.liveDate'));
        return;
    }
    if (endDate === undefined || endDate === '') {
        toastr.error(lang('toastr.leaveDate'));
        return;
    }
    // 初始化返回接口参数
    var originalHref = $('#doc-header a').attr('data-href');
    $('#doc-header a').off('click').attr('href', originalHref + '?hotel=' + currentHotel + '&roomType=' + roomType + '&startDate=' + startDate + '&endDate=' + endDate);

    //会员打折
    var calculateVipContentTotal = function(coupon){
        var roomPrice = $('.book-room-price').text();
        var deposit = $('.book-deposit-price').text();
        var charityPrice = $('.book-charityPrice').text();
        var total = parseFloat(roomPrice) + parseFloat(deposit);
        if(window.minusPrice){
            $('#div-discounts').addClass('hidden');
            charityPrice = charityPrice == '' ? 0 :  charityPrice;
            var price = '';
            if(discount === '0'){
                var price = parseFloat(parseFloat(roomPrice)-parseFloat(charityPrice)) * (discountrule / 10) + parseFloat(deposit)+parseFloat(charityPrice);
            }
            if(discount === '1'){
                window.nights = parseInt($('.book-night').text());
                var priceDifference = parseFloat(total)-parseFloat(deposit)-parseFloat(charityPrice)- parseFloat(discountrule * window.nights * window.rooms);
                var price = parseFloat(parseFloat(priceDifference) + parseFloat(charityPrice)+parseFloat(deposit));
            }
            $('.book-total').text(total.toFixed(2));
            $('.book-price').text((price*100/100).toFixed(2));
            $('#pay-text').text(lang('vip.price'));
            $('#div-total').removeClass('hidden');
        }else{
            if(parseFloat(window.minusPriceValue) > 0){
                $('#div-discounts').removeClass('hidden').find('.book-discounts').text(parseFloat(window.minusPriceValue).toFixed(2));
                $('.book-price').text(parseFloat(parseFloat(roomPrice) -parseFloat(charityPrice) - window.minusPriceValue + + parseFloat(deposit)+parseFloat(charityPrice)).toFixed(2));
            }
        }  
        if(!coupon){
            getShowCoponlist();  
        }    
    }
    //普通成员
    var calculateCommonContentTotal = function(coupon){
        var roomPrice = $('.book-room-price').text();
        var deposit = $('.book-deposit-price').text();
        var charityPrice = $('.book-charityPrice').text();
        var total = parseFloat(roomPrice) + parseFloat(deposit);
        $('.book-price').text(total.toFixed(2));
        $('#div-total').addClass('hidden');
        $('#pay-text').text(lang('prepay'));
        if(parseFloat(window.minusPriceValue) > 0){
            $('#div-discounts').removeClass('hidden').find('.book-discounts').text(parseFloat(window.minusPriceValue).toFixed(2));
            $('.book-price').text(parseFloat(parseFloat(roomPrice)-parseFloat(charityPrice) - window.minusPriceValue + + parseFloat(deposit)+parseFloat(charityPrice)).toFixed(2));
        }
        if(!coupon){
            getShowCoponlist();  
        }      
    }   
    //优惠券
    var getShowCopon = function(){
        if(window.vipInfoId){
            calculateVipContentTotal(true);
        }else{
            calculateCommonContentTotal(true);
        }
        var selectCoupon = $('.select-coupon');
        if(window.nocoupon != undefined){
            selectCoupon.removeClass('hidden');
            selectCoupon.find('.book-coupon').text(window.nocoupon);
        }else if(window.couponName){
            selectCoupon.removeClass('hidden');
            selectCoupon.find('.book-coupon').text(window.couponName);
        }else{
            selectCoupon.addClass('hidden');
        }
        if(window.couponName){
            selectCoupon.removeClass('hidden');
            selectCoupon.find('.book-coupon').text(window.couponName);
            var price = parseFloat($('.book-price').text());
            var charityPrice = parseFloat($('.book-charityPrice').text());
            var deposit = parseFloat($('.book-deposit-price').text());
            var total = price - charityPrice - deposit;
            if(window.couponType == 1){
                totalCoupon = parseFloat(parseFloat(total) - parseFloat(window.couponMinusPrice)+charityPrice+deposit);
            }else{
                totalCoupon =  parseFloat(parseFloat(total)*100*parseFloat(window.couponDiscount)/1000+charityPrice+deposit);
            }
            $('.book-price').text(totalCoupon.toFixed(2));    
        }
    };
    var requestRoomSurplus = function () {
        toggleLoading(true);
        var afterSubmit = $('#requestSubmit');
        afterSubmit.attr('disabled', true);
        ajaxRequest('/Home/Room/bookDetail', {
            'hotel': currentHotel,
            'roomType': roomType,
            'room': roomId,
            'startDate': startDate,
            'endDate': endDate
        }, 'post', function (data) {
            $("#booking-container .first-room").siblings('.room-info').remove();
            $('.select-room').html('');
            toggleLoading(false);
            afterSubmit.removeAttr('disabled');
            var hotelInfo = data.data; 
            window.isSplitOrderTime = hotelInfo.isSplitOrderTime;
            $('#book-calendar .book-date').html(hotelInfo.startDate.substr(5));
            $('#book-calendar .book-night').html(hotelInfo.nights);
            window.adminId = hotelInfo.adminId;
            // 0表示预定房间
            if(hotelInfo.rooms != undefined){
                var rooms = hotelInfo.rooms;
                var roomName = [];
                var roomId = [];
                var roomFirstName = $('.room-name-first');
                for(var i=0;i<rooms.length;i++){
                    roomName.push(rooms[i].roomName);
                    roomId.push(rooms[i].room);
                }
                if(roomName.length<2){
                    roomFirstName.text(roomName[0]).attr('roomId',roomId[0]);
                }else{
                    roomFirstName.text(roomName[0]).attr('roomId',roomId[0]);
                    roomFirstName.next('.switchable').removeClass('hidden');
                    var roomHTML = '';
                    var roomHTMLLi = '';
                    var templateAddRoom = $($('#templateAddRoom').clone().html());
                    var templateAddRoomLi = $($('#templateAddRoomLi').clone().html());
                    for(var i=0;i<roomName.length-1;i++){
                       templateAddRoom.find('.room-type-null span').text(roomName[i+1]).attr('roomId',roomId[i+1]);
                       roomHTML += templateAddRoom.prop('outerHTML');
                    }
                    for(var i=0;i<roomName.length;i++){
                       templateAddRoomLi.text(roomName[i]).attr('roomId',roomId[i]);
                       roomHTMLLi += templateAddRoomLi.prop('outerHTML');
                    }                
                    $('#addRoomHtml').before(roomHTML);
                    $('.select-room').append(roomHTMLLi);
                }                
                // 初始化区号选择
                var areaCode;
                if ($.cookie("area_book_cookie") != 'undefined') {
                    areaCode = $.cookie("area_book_cookie");
                    if (areaCode != undefined) {
                        $('.areaCode').find('.areaCodeValue').text(areaCode);
                    } else {
                        $('.areaCode').find('.areaCodeValue').text('86');
                    }
                }  
                $('.areaCode').on('click', '.dropdown-menu a', function() {
                    var me = $(this),
                    value = me.data('value');
                    me.parents('.areaCode').find('.areaCodeValue').text(value);
                    if ($.cookie("area_book_cookie") != 'undefined') {
                        $.cookie('area_book_cookie', value, { expires: 7, path: '/' });
                    }
                });
            };
            var isBookingRoom = parseInt(hotelInfo.bookMode) === 0;
            var documentBody = $('#doc-body');
            if (isBookingRoom) {
                documentBody.find('.room-name').html(hotelInfo.roomName);
                documentBody.find('.room-type-name').html(hotelInfo.roomTypeName);
                documentBody.find('.room-type-name').removeClass('hidden');
            } else {
                documentBody.find('.room-type-name').html(hotelInfo.roomTypeName);
            }
            documentBody.find('.book-room-price').html(hotelInfo.price);
            if (parseFloat(hotelInfo.deposit) === 0) {
                documentBody.find('.book-price').html(hotelInfo.price);
                documentBody.find('.book-deposit-price').html('0');
            } else {
                documentBody.find('.book-deposit-price').html(hotelInfo.deposit);
                documentBody.find('.book-price').html((parseFloat(hotelInfo.price) + parseFloat(hotelInfo.deposit)).toFixed(2));
            }
            if (parseFloat(hotelInfo.charityPrice) === 0) {
                documentBody.find('.div-charity').addClass('hidden');
                documentBody.find('.book-charity-tip').addClass('hidden');
            } else {
                documentBody.find('.div-charity').removeClass('hidden');
                documentBody.find('.book-charity-tip').removeClass('hidden');
                documentBody.find('.book-charityPrice').html(parseFloat(hotelInfo.charityPrice).toFixed(2));
            }
            if (hotelInfo.rooms) {
                window.rooms = hotelInfo.rooms.length;
            }
            //立减
            window.minusPriceValue = 0;
            if (hotelInfo.minusPrice != 0) {
                window.minusPriceValue = parseFloat(hotelInfo.minusPrice);
            }
            if (parseInt(hotelInfo.minusEnable) == 1 && parseFloat(hotelInfo.minusPrice) > 0) {
                window.minusPrice = false;
            }else{
                window.minusPrice = true;
            };
            if(window.vipInfoId){
                calculateVipContentTotal();
            }else{       
                calculateCommonContentTotal();
            }
        }, function (error) {
            toggleLoading(false);
            toastr.error(typeof error.responseJSON === 'undefined' ? lang('tip.server') : error.responseJSON.info);
        });
    };
    var docBody = $('#doc-body');
    docBody.on('click','.room-type-null',function(e){
        e.preventDefault();
        e.stopPropagation();        
        var selectroom = $(this).find('.select-room');
        if(selectroom.hasClass('hidden')){
            selectroom.removeClass('hidden');
        }else{
            selectroom.addClass('hidden');
        }
        var roomInfo = $(this).closest('.room-info');
        roomInfo.siblings('.room-info').find('.select-room').addClass('hidden');
    });
   docBody.on('click','.create-li',function(e){
        e.preventDefault();
        e.stopPropagation();       
        var li = $(this).text();
        $(this).closest('.room-type-null').find('span').text(li);
        $('.select-room').addClass('hidden');
    });    
    docBody.click(function(){
        $('.select-room').addClass('hidden');
    });
    // 初始化calendar的界面以及监听事件
    var initCalendar = function () {
        var today = $('#doc').data('start');
        $('#book-calendar .book-date').html(startDate.substr(5));
        var interval = getDate(endDate).getDays(getDate(startDate));
        $('#book-calendar .book-night').html(interval);
        var todayDate = getDate(today);
        var endDateTime = endDate;
        var dates = 30;
        if(window.isSplitOrderTime){
            endDateTime = today;
            dates = 29;
        };        
        $('#dateRangePicker').dateRangePickerMobile({
            dateLimit: dates,
            showWeek: false,
            minDate: today,
            maxDate: todayDate.customDays(365).customFormat(),
            startDate: startDate,
            endDate: endDateTime,
            locale: {
                startDateLabel: lang(''),
                endDateLabel: lang('')
            }
        });
        $('#dateRangePicker').on('end.amos.drpm', function (e) {
            startDate = e.startDate;
            endDate = e.endDate;
            var interval = getDate(endDate).getDays(getDate(startDate));
            $('#book-calendar .book-date').html(startDate.substr(5));
            $('#book-calendar .book-night').html(interval);
            $('#calendarModal').modal('hide');
            requestRoomSurplus();
        });
        $('#book-calendar').on('click', function (e) {
            e.preventDefault();
            e.stopPropagation();
            $('#calendarModal').modal('show');
        });
    };
    var initSubmitForm = function () {
        $('#doc-body').inputValidate({
            submit: {
                query: '#sendAgain'
            },
            inputs: [{
                query: '#requestMobile',
                regexp: window.commonRegexp.mobile.regexp,
                message: window.commonRegexp.mobile.message,
                emptyMessage: window.commonRegexp.mobile.emptyMessage
            }, {
                query: '#requestVerifiedCode',
                regexp: window.commonRegexp.imageCode.regexp,
                message: window.commonRegexp.imageCode.message,
                emptyMessage: window.commonRegexp.imageCode.emptyMessage
            }]
        });
        $('#sendAgain').on('successSubmit.amos.inputValidate', function (e) {
            var submitBtn = $(this);
            var params = {};
            params.mobile = $('#requestMobile').val();
            params.verify = $('#requestVerifiedCode').val();
            params.areaCode = submitBtn.closest('.room-info').find('.areaCodeValue').text().trim();
            ajaxRequest('/Home/Order/bookVcode', params, 'post', function (data) {
                timeDisplay($('#sendAgain'), 60);
            }, null, submitBtn);
        });

        $('#booking-container').inputValidate({
            submit: {
                query: '#requestSubmit'
            },
            inputs: [{
                query: '#requestMobile',
                regexp: window.commonRegexp.mobile.regexp,
                message: window.commonRegexp.mobile.message,
                emptyMessage: window.commonRegexp.mobile.emptyMessage
            },{
                query: 'input[name=requestMobileNext]',
                regexp: window.commonRegexp.mobile.regexp,
                message: lang('tip.mobile'),
                emptyMessage: lang('tip.mobileNull')
            }, {
                query: '#requestName',
                regexp: /^.{1,20}$/,
                message: lang('tip.name'),
                emptyMessage: lang('tip.nameNull')
            }]
        });
        $('#requestSubmit').on('successSubmit.amos.inputValidate', function (e) {
            var submitBtn = $(this);
            window.params = '';
            var roomName = $('.room-type-null');
            var roomNameArr = [];
            for(var i=0;i<roomName.length;i++){
                var room = roomName.eq(i).find('span').text();
                roomNameArr.push(room);
            }
            var ary = roomNameArr.join(",") +",";
            for(var i = 0; i < roomNameArr.length; i++){
               if(ary.replace(roomNameArr[i] + ",", "").indexOf(roomNameArr[i] +",") > -1){
                    formInlineTip(submitBtn, lang('room')+roomNameArr[i]+lang('repeat'));
                    return;
                }
            }
            var params = {};
            if (!isUserLogined) {
                params.vcode = $('#requestMobileCode').val();
                if (params.vcode === null || params.vcode.length === 0) {
                    formInlineTip(submitBtn, lang('tip.messageNull'));
                    return;

                }
                if (!(/^\d{4}$/.test(params.vcode))) {
                    formInlineTip(submitBtn, lang('tip.message'));
                    return;
                }
            }
            var roomName = [],mobile = [],address = [],nationality = [],
                IdNum = [],sex = [],arrInfo = [],areaCodeArr = [];
            var requestMobileVal = $('.requestMobileVal');
            var requestNameVal = $('.requestNameVal');
            var areaCodeValue = $('.areaCodeValue');
            var requestIdCardVal = $('.requestIdCardVal');
            var roomInfo = $('.room-info');
            for(var i=0;i< requestMobileVal.length;i++){
                mobile.push(requestMobileVal.eq(i).val());
                areaCodeArr.push(areaCodeValue.eq(i).text().trim());
                var isName = requestNameVal.eq(i).val();
                if(isName == ''){
                    isName = requestNameVal.eq(0).val();
                }
                roomName.push(isName);
                IdNum.push(requestIdCardVal.eq(i).val());
                if(roomInfo.eq(i).data('sex') !== undefined){
                    sex.push(roomInfo.eq(i).data('sex'));
                }
                if(roomInfo.eq(i).data('nationality') !== undefined){
                    nationality.push(roomInfo.eq(i).data('nationality'));
                }
                if(roomInfo.eq(i).data('address') !== undefined){
                    address.push(roomInfo.eq(i).data('address'));
                }
            }
            if(roomId != undefined){
                for(var i=0;i<roomId.length;i++){
                    var obj = {};
                    obj.room = roomId[i];
                    obj.name = roomName[i];
                    obj.mobile = mobile[i];
                    obj.areaCode = areaCodeArr[i];
                    obj.idnation = nationality[i];
                    obj.identity = IdNum[i];
                    obj.idsex = sex[i];
                    obj.idaddress = address[i];
                    arrInfo.push(obj);
                }                     
            }else{
                var obj = {};
                obj.name = roomName[0];
                obj.mobile = mobile[0]; 
                obj.areaCode = areaCodeArr[0]; 
                obj.idnation = nationality[0];
                obj.identity = IdNum[0];
                obj.idsex = sex[0];
                obj.idaddress = address[0]; 
                arrInfo.push(obj);              
            }
            params.hotel = currentHotel;
            params.roomType = roomType;
            params.startDate = startDate;
            params.endDate = endDate;
            params.users = arrInfo;
            params.type = 0;
            if(window.isSplitOrderTime){
                params.type = 1;
            }        
            if(window.userGetNo !== undefined){
                params.userGetNo = userGetNo;
            }
            window.params = params;
            ajaxRequest('/Home/Order/book', params, 'post', function (data) {
                var orderNumber = data.data.orderNumber;
                var roomIds = data.data.roomIds;
                var orderHotel = data.data.orderHotel;
                var isOffline = data.data.isOffline;
                var ai = data.data.ai;
                var asc = data.data.asc;
                var alipay = data.data.ali == 0;
                var vipcardpay = data.data.vipcardpay == 1;
                var wechatpay = data.data.wechat == 0;
                var wechat = 0;
                if(wechatpay && vipcardpay){
                    wechat = 2;
                };
                var pay = 1;
                if(alipay && vipcardpay){
                    pay = 2;
                };
                if (!roomId && roomIds) {
                    window.roomFirst = roomIds;
                }
                if(isOffline){
                    window.location.href = "/Home/OrderPage/index?hotel=" + currentHotel + "&no=" + orderNumber;
                }else{
                    if(isWechatBrowser()){
                        window.location.href = 'http://cz.uclbrt.com/Wechat/WechatLoginPage/auth.html?type=mz&hotel=' + currentHotel + '&no=' + orderNumber + '&orderHotel=' + orderHotel + '&back=/Home/PayPage/speedpay.html&pay='+wechat+'&ai='+ai+'&asc='+asc;
                    }else{
                        window.location.href = "/Home/PayPage/speedpay?hotel=" + currentHotel + "&no=" + orderNumber+'&pay='+pay+ '&orderHotel=' + orderHotel;                    
                    }                    
                }
            }, function(error){
                var checkOrderModal = $('#checkOrderModal'); 
                if(error.responseJSON.status == '1214'){
                    checkOrderModal.find('.message').text(error.responseJSON.data);
                    $('#checkOrderModal').modal('show');
                }else{
                    formInlineTip(submitBtn, error.responseJSON.info);
                };
            }, submitBtn);
        });
    };
    initSubmitForm();
    $('#requestAgainSubmit').on('click',function(e){
        e.stopPropagation();
        var submitBtn = $('#requestSubmit');
        var params = window.params;
        params.type = 0;
        ajaxRequest('/Home/Order/book', params, 'post', function (data) {
            var orderNumber = data.data.orderNumber;
            var roomIds = data.data.roomIds;
            if (!roomId && roomIds) {
                window.roomFirst = roomIds;
            }
            window.location.href = "/Home/OrderPage/index?hotel=" + currentHotel + "&no=" + orderNumber;
        }, null, submitBtn); 
    });

    // 用户个人信息
    var isUserLogined = true;
    var userInfo = {};
    var requestUserInfo = function () {
        ajaxRequest('/Home/User/info', {hotel : currentHotel}, 'post', function (data) {
            userInfo = data.data;
            $('#requestMobile').val(userInfo.mobile);
            $('#requestName').val(userInfo.name);
            $('#requestIdCard').val(userInfo.identity);
            $('.first-room .areaCodeValue').text(userInfo.areaCode);
            $('.first-room').data('nationality',userInfo.idnation);
            $('.first-room').data('address',userInfo.idaddress);
            $('.first-room').data('sex',userInfo.idsex);    
            var authLogin = parseInt(userInfo.authLogin);
            var bindMobile = parseInt(userInfo.bindMobile);
            if(userInfo.vipInfo){
                window.discount = userInfo.vipInfo.discount;
                window.discountrule = userInfo.vipInfo.discountrule;
                window.vipInfoId = userInfo.vipInfo.id;
            }
            if (authLogin === 3 && bindMobile === 0) {
                isUserLogined = false;
                $('#requestCodeContainer').removeClass('hidden');
                $('#requestPicCodeContainer').removeClass('hidden');
            } else {
                isUserLogined = true;
            }
        }, function (error) {
            isUserLogined = false;
            $('#requestCodeContainer').removeClass('hidden');
            $('#requestPicCodeContainer').removeClass('hidden');
        });
    };
    $('#requestMobile').change(function () {
        var $me = $(this);
        var moblie = $me.val();
        var areaCode = $me.closest('.form-group').find('.areaCodeValue').text().trim();
        if (window.commonRegexp.mobile.regexp.test(moblie)) {
            var params = {
                hotel : currentHotel,
                mobile : moblie,
                areaCode : areaCode,
            }
            ajaxRequest('/Home/User/getVipInfo', params, 'post', function (data) {
                vipInfo = data.data;
                if(vipInfo == ''){
                    window.vipInfoId = false;
                    calculateCommonContentTotal();
                }else{
                    window.vipInfoId = vipInfo.id;
                    window.discount = vipInfo.discount;
                    window.discountrule = vipInfo.discountrule;
                    calculateVipContentTotal();
                }
            }, null, $me);
        } else {
            window.vipInfoId = false;
            calculateCommonContentTotal();
        }
    });
    $('#requestMobile').on('blur',function(){
        var $me = $(this);
        var moblie = $me.val();
        if(moblie == ''){
            calculateCommonContentTotal();
        }
    });    
    requestUserInfo();
    setTimeout(function(){
        requestRoomSurplus();
        initCalendar();
    },200);
    
    var getShowCoponlist = function(){
        var selectCoupon = $('.select-coupon');
        var unuseCoupon = $('.unuse-coupon').clone();
        var price = parseFloat($('.book-price').text())-parseFloat($('.book-deposit-price').text());
        var charityPrice = parseFloat($('.book-charityPrice').text()); 
        price = price.toFixed(2);
        unuseCoupon.find('.icon').removeClass('active');
        ajaxRequest('/Home/Coupon/getUserCouponCanBook', {
            "hotel": currentHotel,
            "roomTypeId": roomType,
            "price": price,
            "charityPrice": charityPrice
        }, 'post', function (data) {
            var info = data.data;
            var couponHTML = '';
            if(info.length !==0 ){
                window.userGetNo =info[0].userGetNo;
                window.couponName =info[0].couponName;
                window.couponType = info[0].couponType;
                window.couponMinusPrice = info[0].couponMinusPrice;
                window.couponDiscount = info[0].couponDiscount;             
                $.each(info, function (key, value) {
                    var templateCouponHTML = $($('#templateCoupon').clone().html());
                    templateCouponHTML.find('.coupon').text(value.couponName);
                    templateCouponHTML.attr({
                        'data-userget':value.userGetNo,
                        'data-type':value.couponType,
                        'data-price':value.couponMinusPrice,
                        'data-discount':value.couponDiscount,
                        'data-name':value.couponName
                    });
                    if(key == 0){
                        templateCouponHTML.find('.icon').addClass('active');
                    }
                    couponHTML += templateCouponHTML.prop('outerHTML');
                });
                $('.coupon-content').html(couponHTML).append(unuseCoupon);
                getShowCopon();
            }else{
                selectCoupon.addClass('hidden');
            }
        }, function(error){
            toastr.error(typeof error.responseJSON === 'undefined' ? lang('tip.server') : error.responseJSON.info);
        });           
    };
   
    $('.coupon-content').on('click','.type-list',function(e){
        e.stopPropagation();
        var btn = $(this);
        btn.find('.icon').addClass('active');
        btn.siblings('.type-list').find('.icon').removeClass('active');
        window.userGetNo = btn.data('userget');
        window.couponType = btn.data('type');
        window.couponMinusPrice = btn.data('price');
        window.couponDiscount = btn.data('discount');
        window.couponName = btn.data('name');
        window.nocoupon = btn.data('nocoupon');
        getShowCopon();
    });
    $('.select-coupon ').on('click',function(e){
        e.stopPropagation();
        $('.coupon-container').removeClass('hidden');
    });
    $('.coupon-type').on('click','.coupon-close',function(e){
        e.stopPropagation();
        $('.coupon-container').addClass('hidden');
    });
});
